#!/usr/bin/perl
use strict;
use loft;
open LIST or die "$LIST: $!";
open OUT,'>',$OUT or die "OUT: $!";
my $pnow=$hdr;
my $index='';
sysseek OUT,$pnow,0;

while (<LIST>)
{chomp;my ($id,$name)=split / /,$_,2;
$id=~s/^0+//;
my $rname=loft::rname($name);
warn "$rname not exists" unless -e $rname;
open DX,$rname or warn "$rname: $!" and next;
binmode DX;
syswrite OUT,$_ while sysread DX,$_,1024*1024;
close DX;
my $ptr=sysseek OUT,0,1;
$index.="$pnow $ptr $id $pnow $name\n";
$pnow=$ptr;
}
close LIST;
syswrite OUT,$index;
sysseek OUT,0,0;
syswrite OUT,sprintf "%0${hdr}u",$pnow;
close OUT;
